package com.falm.picturebackend.exception;

import lombok.Getter;

/**
 * @author Administrator
 */
@Getter
public class BusinessException extends RuntimeException {

    /**
     * 错误信息
     */
    private final String code;

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

    public BusinessException(String message, ErrorCode errorCode) {
        super(message);
        this.code = errorCode.getCode();
    }

    public BusinessException(String message, Throwable cause, ErrorCode errorCode) {
        super(message, cause);
        this.code = errorCode.getCode();
    }

    public BusinessException(Throwable cause, ErrorCode errorCode) {
        super(cause);
        this.code = errorCode.getCode();
    }

    public BusinessException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace,
        ErrorCode errorCode) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.code = errorCode.getCode();
    }

    public BusinessException(ErrorCode errorCode, String message) {
        super(message);
        this.code = errorCode.getCode();
    }
}
